package com.project.customview.algorithm;

import android.support.annotation.NonNull;
//对象排序
public class Card implements Comparable{
    public int pokerColors;//花色
    public int cardPoints; //点数

    public Card(int pokerColors, int cardPoints) {
        this.pokerColors = pokerColors;
        this.cardPoints = cardPoints;
    }

    //该方法比较对象大小
    @Override
    public int compareTo(@NonNull Object obj) {
        Card c = (Card) obj;
        if (this.cardPoints>c.cardPoints){
            return 1;
        }else if (this.cardPoints<c.cardPoints){
            return -1;
        }
        if (this.pokerColors>c.pokerColors){
            return 1;
        }else if (this.pokerColors<c.pokerColors){
            return -1;
        }
        return 0;

    }

    @Override
    public String toString() {
        return "Card{" +
                "pokerColors=" + pokerColors +
                ", cardPoints=" + cardPoints +
                '}';
    }
}
